package xyx.ysfwpt.service;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import xyx.ysfwpt.dao.UserDao;
import xyx.ysfwpt.model.User;

import javax.annotation.Resource;
import java.util.List;

@Service("UserService")
public class UserServiceImpl implements UserService{
    @Resource
    UserDao userDao;

    @Override
    public User selectUserByName(String username){
        return userDao.selectUserByName(username);
    }

    public List<User> selectAllUser(){
        return userDao.selectAllUser();
    }

    public User selectUserByJobNumber(int job_number){
        return userDao.selectUserByJobNumber(job_number);
    }

    public List<User> selectUserByDirector(int director){
        return userDao.selectUserByDirector(director);
    }

    public List<User> selectUserByInputList(@Param(value = "department") String department,
                                            @Param(value = "clinical_title") String clinical_title,
                                            @Param(value = "teaching_title") String teaching_title,
                                            @Param(value = "type") String type,
                                            @Param(value = "source") String source,
                                            @Param(value = "state") Integer state,
                                            @Param(value = "searchword") String searchword,
                                            @Param(value = "job_number") Integer job_number,
                                            @Param(value = "user_type") String user_type,
                                            @Param(value = "timefrom") String timefrom,
                                            @Param(value = "timeto") String timeto,
                                            @Param(value = "searchtype") Integer searchtype){
        return userDao.selectUserByInputList(department,clinical_title,teaching_title,type,source,state,searchword,job_number,user_type,timefrom,timeto,searchtype);
    }

    public void addUser(User user){
        userDao.addUser(user);
    }

    public void updateUser(User user){
        userDao.updateUser(user);
    }

    public void updateUser2(User user){
        userDao.updateUser2(user);
    }

    public void updateUserPhoto(int job_number,String imgurl) {
        userDao.updateUserPhoto(job_number,imgurl);
    }

    public void updateUserPSW(int job_number,String password) {
        userDao.updateUserPSW(job_number,password);
    }

    public void updateDepartment(@Param(value = "job_number") int job_number, @Param(value = "department") String department, @Param(value = "director") int director) {
        userDao.updateDepartment(job_number,department,director);
    }

    public void updateState(@Param(value = "job_number") int job_number, @Param(value = "state") Integer state) {
        userDao.updateState(job_number,state);
    }

    public void updateIslock(@Param(value = "job_number") int job_number, @Param(value = "islock") Integer islock) {
        userDao.updateIslock(job_number,islock);
    }

    public void deleteUser(int job_number) {
        userDao.deleteUser(job_number);
    }

    public List<User> selectIsLock2(@Param(value = "islock2") Integer islock2){
        return userDao.selectIsLock2(islock2);
    }

    public  void updateIsLock2(@Param(value = "job_number") int job_number,
                               @Param(value = "islock2") Integer islock2,
                               @Param(value = "locktime") String locktime){
        userDao.updateIsLock2(job_number,islock2,locktime);
    }

}
